<template>
	<view class="container">
		<view class="example">
			<uni-forms ref="form" :model="scfzjc" label-width="100px" >
				<!-- B超 -->
				<uni-section title="B超" type="line"></uni-section>
				<uni-forms-item label="病灶（cm）" name="bcBzCd">
					<uni-row class="demo-uni-row">
						<uni-col :span="6">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.bcBzCd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
						<uni-col :span="3" class="wbkx">x</uni-col>
						<uni-col :span="6">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.bcBzKd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
						<uni-col :span="3" class="wbkx">x</uni-col>
						<uni-col :span="6">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.bcBzGd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
					</uni-row>
				</uni-forms-item>
				<uni-forms-item label="淋巴结（cm）" name="bcLbjCd">
					<uni-row class="demo-uni-row">
						<uni-col :span="11">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.bcLbjCd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
						<uni-col :span="2" class="wbkx">x</uni-col>
						<uni-col :span="11">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.bcLbjKd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
					</uni-row>
				</uni-forms-item>
				<uni-forms-item label="BI-RADS分类" name="bcBiRads">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.bcBiRads" type="digit"  @change="autoSaven" placeholder="请输入BI-RADS分类" />
				</uni-forms-item>
				
				<!-- 钼靶 -->
				<uni-section title="钼靶" type="line"></uni-section>
				<uni-forms-item label="病灶（cm）" name="mbBzCd">
					<uni-row class="demo-uni-row">
						<uni-col :span="11">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.mbBzCd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
						<uni-col :span="2" class="wbkx">x</uni-col>
						<uni-col :span="11">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.mbBzKd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
					</uni-row>
				</uni-forms-item>
				<uni-forms-item label="淋巴结（cm）" name="mbLbjCd">
					<uni-row class="demo-uni-row">
						<uni-col :span="11">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.mbLbjCd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
						<uni-col :span="2" class="wbkx">x</uni-col>
						<uni-col :span="11">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.mbLbjKd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
					</uni-row>
				</uni-forms-item>
				<uni-forms-item label="BI-RADS分类" name="mbBiRads">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.mbBiRads" type="digit"  @change="autoSaven" placeholder="请输入BI-RADS分类" />
				</uni-forms-item>
				
				<!-- 磁共振 -->
				<uni-section title="磁共振" type="line"></uni-section>
				<uni-forms-item label="病灶（cm）" name="cgzBzCd">
					<uni-row class="demo-uni-row">
						<uni-col :span="6">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.cgzBzCd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
						<uni-col :span="3" class="wbkx">x</uni-col>
						<uni-col :span="6">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.cgzBzKd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
						<uni-col :span="3" class="wbkx">x</uni-col>
						<uni-col :span="6">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.cgzBzGd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
					</uni-row>
				</uni-forms-item>
				<uni-forms-item label="淋巴结（cm）" name="cgzLbjCd">
					<uni-row class="demo-uni-row">
						<uni-col :span="11">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.cgzLbjCd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
						<uni-col :span="2" class="wbkx">x</uni-col>
						<uni-col :span="11">
							<uni-easyinput :disabled="isDisabled" v-model="scfzjc.cgzLbjKd" type="digit"  @change="autoSaven" placeholder="请输入大小（cm）" />
						</uni-col>
					</uni-row>
				</uni-forms-item>
				<uni-forms-item label="ADC值" name="cgzAdc">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.cgzAdc"  @change="autoSaven" placeholder="请输入ADC" />
				</uni-forms-item>
				<uni-forms-item label="BI-RADS分类" name="cgzBiRads">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.cgzBiRads" type="digit"  @change="autoSaven" placeholder="请输入BI-RADS分类" />
				</uni-forms-item>
				
				<!-- 血常规 -->
				<uni-section title="血常规" type="line"></uni-section>
				<uni-forms-item label="白细胞（10^9/L）" name="xcgBxb">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.xcgBxb"  @change="autoSaven" placeholder="请输入白细胞" />
				</uni-forms-item>
				<uni-forms-item label="中性粒细胞（10^9/L）" name="xcgZxlxb">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.xcgZxlxb"  @change="autoSaven" placeholder="请输入中性粒细胞" />
				</uni-forms-item>
				<uni-forms-item label="红细胞（10^12/L）" name="xcgHxb">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.xcgHxb"  @change="autoSaven" placeholder="请输入红细胞" />
				</uni-forms-item>
				<uni-forms-item label="血小板（10^9/L）" name="xcgXxb">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.xcgXxb"  @change="autoSaven" placeholder="请输入血小板" />
				</uni-forms-item>
				
				<!-- 肿瘤标志物 -->
				<uni-section title="肿瘤标志物" type="line"></uni-section>
				<uni-forms-item label="CEA（ng/mL）" name="zlbzwGea">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.zlbzwGea"  @change="autoSaven" placeholder="请输入CEA" />
				</uni-forms-item>
				<uni-forms-item label="CA199（U/mL）" name="zlbzwCa199">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.zlbzwCa199"  @change="autoSaven" placeholder="请输入CA199" />
				</uni-forms-item>
				<uni-forms-item label="CA15-3（U/mL）" name="zlbzwCa153">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.zlbzwCa153"  @change="autoSaven" placeholder="请输入CA15-3" />
				</uni-forms-item>
				<uni-forms-item label="CA125（U/mL）" name="zlbzwCa125">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.zlbzwCa125"  @change="autoSaven" placeholder="请输入CA125" />
				</uni-forms-item>
				
				<!-- 生化 -->
				<uni-section title="生化" type="line"></uni-section>
				<uni-forms-item label="肌酐（μmoI/L）" name="shJg">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.shJg"  @change="autoSaven" placeholder="请输入肌酐" />
				</uni-forms-item>
				<uni-forms-item label="ALT（U）" name="shAlt">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.shAlt"  @change="autoSaven" placeholder="请输入ALT" />
				</uni-forms-item>
				<uni-forms-item label="AST（U）" name="shAst">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.shAst"  @change="autoSaven" placeholder="请输入AST" />
				</uni-forms-item>
				<uni-forms-item label="碱性磷酸酶（U/L）" name="shJxlsm">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.shJxlsm"  @change="autoSaven" placeholder="请输入碱性磷酸酶" />
				</uni-forms-item>
				
				<!-- 电解质 -->
				<uni-section title="电解质" type="line"></uni-section>
				<uni-forms-item label="钠（mmol/L）" name="djzNa">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.djzNa"  @change="autoSaven" placeholder="请输入钠" />
				</uni-forms-item>
				<uni-forms-item label="钾（mmol/L）" name="djzJia">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.djzJia"  @change="autoSaven" placeholder="请输入钾" />
				</uni-forms-item>
				<uni-forms-item label="镁（mmol/L）" name="djzMei">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.djzMei"  @change="autoSaven" placeholder="请输入镁" />
				</uni-forms-item>
				<uni-forms-item label="钙（mmol/L）" name="djzGai">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.djzGai"  @change="autoSaven" placeholder="请输入钙" />
				</uni-forms-item>
				
				<!-- 激素 -->
				<uni-section title="激素" type="line"></uni-section>
				<uni-forms-item label="孕酮（nmo1/L）" name="jsYt">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.jsYt"  @change="autoSaven" placeholder="请输入孕酮" />
				</uni-forms-item>
				<uni-forms-item label="雌二醇（pmo1/L）" name="jsXec">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.jsXec"  @change="autoSaven" placeholder="请输入雌二醇" />
				</uni-forms-item>
				<uni-forms-item label="卵泡刺激素（IU/L）" name="jsNbcjs">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.jsNbcjs"  @change="autoSaven" placeholder="请输入卵泡刺激素" />
				</uni-forms-item>
				<uni-forms-item label="促黄体生成素（IU/L）" name="jsChtscs">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.jsChtscs"  @change="autoSaven" placeholder="请输入促黄体生成素" />
				</uni-forms-item>
				<uni-forms-item label="泌乳素（μg/L）" name="jsMrs">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.jsMrs"  @change="autoSaven" placeholder="请输入泌乳素" />
				</uni-forms-item>
				<uni-forms-item label="睾酮（nmo1/L）" name="jsGt">
					<uni-easyinput :disabled="isDisabled" v-model="scfzjc.jsGt"  @change="autoSaven" placeholder="请输入睾酮" />
				</uni-forms-item>
				
				<!-- 其他 -->
				<uni-section title="其他" type="line"></uni-section>
				<uni-forms-item label="备注" name="remark">
					<uni-easyinput type="textarea" autoHeight :disabled="isDisabled" v-model="scfzjc.remark"  @change="autoSaven" placeholder="请输入备注"/>
				</uni-forms-item>
				<button type="primary" :disabled="isDisabled" @click="submit">保存</button>
			</uni-forms>
		</view>
	</view>
</template>

<script>
	import storage from '@/utils/storage'
import { updateScfzjc,getDicts,sfkybjData } from "@/api/trms/trms"
import { getScfzjc } from "@/api/trms/query"
export default {
	data() {
		return {
			patientId: null,
			isDisabled: false,
			userId: null,
			// 表单数据
			scfzjc: {},
			rules: {
				admissionNumber: {
				  rules: [{
					required: true,
					errorMessage: '住院号不能为空'
				  }]
				}
			}
		}
	},
	onLoad: function(option) {
		this.patientId = option.patientId;
		this.userId = option.userId;
		sfkybjData(this);
		console.log("进入基本信息页面后、参数：",this.patientId)
		if(this.patientId){
			// 查询详情
			this.getDataByPatientId();
		}
	},
	onReady() {
		this.$refs.form.setRules(this.rules)
	},
	methods: {
		/**
		 * 获取数据
		 */
		getDataByPatientId(){
			getScfzjc(this.patientId).then(response => {
			  this.scfzjc = response.data;
			});
		},
		/**
		 * 修改
		 */
		submit(){
			this.$refs.form.validate().then(res => {
				updateScfzjc(this.scfzjc).then(response => {
				  if(response.code == 200){
					  this.$modal.msgSuccess("修改成功");
					  this.backWork();
					  return;
				  }
				  this.$modal.msgError(response.msg);
				});
			})
		},
		autoSaven(){
			this.$refs.form.validate().then(res => {
				updateScfzjc(this.scfzjc).then(response => {
				  console.log("修改成功");
				});
			})
		},
		/**
		 * 回到工作页面
		 */
		backWork(){
			setTimeout(function (){
				uni.navigateBack({
					delta: 1
				});
			},500);
		}
	}
}
</script>


<style lang="scss">
  page {
    background-color: #ffffff;
  }

  .example {
    padding: 15px;
    background-color: #fff;
  }

  .segmented-control {
    margin-bottom: 15px;
  }

  .button-group {
    margin-top: 15px;
    display: flex;
    justify-content: space-around;
  }

  .form-item {
    display: flex;
    align-items: center;
    flex: 1;
  }

  .button {
    display: flex;
    align-items: center;
    height: 35px;
    line-height: 35px;
    margin-left: 10px;
  }
  .wbkx{
  	  text-align: center;
  	  margin-top: 10px;
  }
</style>
